/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package org.sbbs.artemislearn;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 *
 * @author jenkins
 */
@Slf4j
@Component
public class Sender {

    @Autowired
    JmsTemplate jmsTemplate;// = context.getBean(JmsTemplate.class);

    // Send a message with a POJO - the template reuse the message converter
//        System.out.println("Sending an email message.");
//        jmsTemplate.convertAndSend("mailbox", new Email("info@example.com", "Hello"));
//        jmsTemplate.convertAndSend("mailbox1", new Email("info@example.com", "Hello"));
//      
    @Scheduled(fixedRate = 10)
    public void send() {
        jmsTemplate.convertAndSend("mailbox", new Email("info@example.com", "Hello"));
        log.info("producer send a message to mailbox.");
    }
}
